<template>
  <div class="ai-guide">
    <Head></Head>
    <ButtonGroup @create="createDialogue"></ButtonGroup>

    <div class="docter">
      <div class="countdown">{{ countdown }}s</div>
      <img src="../../assets/images/docter.png" />
      <div class="docter-text">
        <p>
          您好，我是**医院导诊护士，请描述您的症状或疾病，让我来为您智能推荐科室就诊！
        </p>
      </div>
    </div>
    <div class="keyboard" @click="goText">
      <img src="../../assets/images/keybord.png" />
      <span>文字输入</span>
    </div>
    <div class="talk" @click="goVoice">
      <img src="../../assets/images/talk.png" />
      <span>开始说话</span>
    </div>
    <BasicDialog v-model="isDialogVisible" />
  </div>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";
import { ref, onMounted, onUnmounted } from "vue";

const router = useRouter();
const countdown = ref(500);
const isDialogVisible = ref(true);

let timer: any;
onMounted(() => {
  isDialogVisible.value = true; // 页面加载后自动显示对话框
  timer = setInterval(() => {
    if (countdown.value > 0) {
      countdown.value--;
    } else {
      clearInterval(timer);
      router.push("/home");
    }
  }, 1000);
});
const goText = () => {
  router.push("/text");
};
const goVoice = () => {
  // 使用显式类型指定

  router.push({
    path: "/voice",
    query: {
      startVisible: 1, //1显示stop 0显示开始
    },
  });
};
const createDialogue = () => {
  router.push("/text");
};

onUnmounted(() => {
  clearInterval(timer);
});
</script>

<style lang="scss" scoped>
@import "./styles/common.scss";
.ai-guide {
  @include container;

  .docter {
    display: flex;
    align-items: center;
    flex-direction: column;
    border-top: 1px solid #a0cef3;
    box-shadow: 0 -5px 10px rgba(0, 0, 0, 0.1); /* 上边框阴影 */

    position: relative;
    .countdown {
      position: absolute;
      top: 30px;
      right: 20px;
      font-size: 40px;
      color: #d82f2f;
    }

    .docter-text {
      width: 92vw;
      height: 18vh;
      background-color: #ffffff;
      border-radius: 16px;
      overflow: hidden;
      position: absolute;
      bottom: 4vh;
      opacity: 0.8;

      p {
        margin: 70px auto;
        font-size: 50px;
        line-height: 80px;
        text-align: center;
        color: #003f71;
      }
    }
  }
  .keyboard {
    width: 28vw;
    height: 5vh;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10vw;
    margin-top: 6vh;
    span {
      font-size: 36px;
      color: #0179ff;
      margin-left: 20px;
    }
  }
  .talk {
    width: 90vw;
    height: 7vh;
    background: linear-gradient(to right, #0077ff, #2fe7f5);
    border-radius: 70px;
    overflow: hidden;
    margin: 5vh auto;
    display: flex;
    align-items: center;
    justify-content: center;
    span {
      font-size: 40px;
      color: #e6f3fc;
      margin-left: 10px;
    }
  }
}
</style>
